package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.ArchiveBag;
import com.hiultra.archive.service.IArchiveBagService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 档案袋Controller
 * 
 * @author paidaxing
 * @date 2024-09-25
 */
@RestController
@RequestMapping("/archive/ArchiveBag")
public class ArchiveBagController extends BaseController
{
    @Autowired
    private IArchiveBagService archiveBagService;

    /**
     * 查询档案袋列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBag:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArchiveBag archiveBag)
    {
        startPage();
        List<ArchiveBag> list = archiveBagService.selectArchiveBagList(archiveBag);
        return getDataTable(list);
    }

    /**
     * 导出档案袋列表
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBag:export')")
    @Log(title = "档案袋", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArchiveBag archiveBag)
    {
        List<ArchiveBag> list = archiveBagService.selectArchiveBagList(archiveBag);
        ExcelUtil<ArchiveBag> util = new ExcelUtil<ArchiveBag>(ArchiveBag.class);
        util.exportExcel(response, list, "档案袋数据");
    }

    /**
     * 获取档案袋详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBag:query')")
    @GetMapping(value = "/{bagId}")
    public AjaxResult getInfo(@PathVariable("bagId") String bagId)
    {
        return AjaxResult.success(archiveBagService.selectArchiveBagByBagId(bagId));
    }

    /**
     * 新增档案袋
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBag:add')")
    @Log(title = "档案袋", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArchiveBag archiveBag)
    {
        return toAjax(archiveBagService.insertArchiveBag(archiveBag));
    }

    /**
     * 修改档案袋
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBag:edit')")
    @Log(title = "档案袋", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArchiveBag archiveBag)
    {
        return toAjax(archiveBagService.updateArchiveBag(archiveBag));
    }

    /**
     * 删除档案袋
     */
    @PreAuthorize("@ss.hasPermi('archive:ArchiveBag:remove')")
    @Log(title = "档案袋", businessType = BusinessType.DELETE)
	@DeleteMapping("/{bagIds}")
    public AjaxResult remove(@PathVariable String[] bagIds)
    {
        return toAjax(archiveBagService.deleteArchiveBagByBagIds(bagIds));
    }
}
